package com.java01.lang.io;

import java.io.IOException;
import java.io.InputStream;

public class GetResourceFromJar {

	public GetResourceFromJar(){
		InputStream is= getClass().getResourceAsStream("/readme.txt");
		
		byte[] buffer = new byte[1024];
		int length;
		try {
			while((length=is.read(buffer))!=-1){
				System.out.println(">>"+new String(buffer,0,length));
				// or specify an encoding for data
				//System.out.println(">>"+new String(buffer,0,length,"BIG5"));
				//System.out.println(">>"+new String(buffer,0,length,"GB2312"));
				//System.out.println(">>"+new String(buffer,0,length,"UTF-8"));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		new GetResourceFromJar();
	}
}
